home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / copymove.swg / 0014_Rename File #2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  1.6 KB  |  48 lines

  1. {
  2. >I am interested in the source in Assembler or TP to move a File from one
  3. >directory to another by means of the FAT table.  I have seen several
  4. >small utilities to do this but I was unable to understand them after
  5. >reverse engineering/disassembly.  (Don't worry, they were PD).  <G>
  6. >Anyway, any help would be appreciated.  Thanks.
  7.  
  8. You don't Really need to do much. Dos Interrupt (21h), Function 56h, will
  9. rename a File, and in essence move it if the source and destination
  10. directories are not the same. That's all there is to it. I know Function
  11. 56h is available in Dos 3.3 and above. I am not sure about prior
  12. versions.
  13.  
  14. On entry: AH      56H
  15.           DS:DX   Pointer to an ASCIIZ String containing the drive, path,
  16.                   and Filename of the File to be renamed.
  17.           ES:DI   Pointer to an ASCIIZ String containing the new path and
  18.                   Filename
  19. On return AX      Error codes if carry flag set, NONE if carry flag not set
  20.  
  21. Below is some crude TP code I Typed on the fly. It may not be exactly right
  22. but you get the idea.
  23. }
  24.  
  25. Uses
  26.   Dos;
  27. Var
  28.   Regs        : Registers;
  29.   Source,
  30.   Destination : PathStr;
  31.  
  32. begin
  33.   { Add an ASCII 0 at the end of the Strings to male them ASCIIZ
  34.     Strings, without actually affecting their actual lengths }
  35.   Source[ord(Source[0])] := #0;
  36.   Destination[ord(Destination[0])] := #0;
  37.  
  38.   { Set the Registers }
  39.   Regs.AH := $56;
  40.   Regs.DS := Seg(Source[1]);
  41.   Regs.DX := ofs(Source[1]);
  42.   Regs.ES := Seg(Destination[1]);
  43.   Regs.DI := ofs(Destination[1]);
  44.  
  45.   { Do the Interrupt }
  46.   Intr($21,Regs);
  47. end.
  48.